<!DOCTYPE html>

<html>
<head>
    <title>微应用登陆</title>
    <meta charset="utf-8">
<!--    <meta name="viewport" content="width=device-width,initial-scale=1 user-scalable=0" />-->
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, minimal-ui">
    <meta content="yes" name="apple-mobile-web-app-capable">
    <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
    <script type="text/javascript" src="https://g.alicdn.com/dingding/dingtalk-jsapi/2.10.3/dingtalk.open.js"></script>
    <script src="https://g.alicdn.com/dingding/dingtalk-jsapi/2.7.13/dingtalk.open.js"></script><!--钉钉JSAPI库（使用对象dd）-->
    <script type="text/javascript" src="http://g.alicdn.com/dingding/dingtalk-pc-api/2.3.1/index.js"></script><!--钉钉JSAPI库（PC端专用——使用对象DingTalkPC）-->
    <script language=javascript>
        setTimeout("document.form1.submit()",1000)
    </script>
    <script type="text/javascript">
        dd.ready(function() {

            dd.runtime.permission.requestAuthCode({
                corpId : "dingf97ce2b254d1552e" ,  //企业id
                onSuccess : function(result) {
                    //这里是把获取到的code填写到表单里面提交，可以采用ajax来提交。但是感觉修改会很麻烦
                    document.getElementById("code").value = result.code;
                },
                onFail : function(err) {
                    alert('出错了, ' + err);
                }
            });

            //这个函数用于判断登录的是电脑还是手机，设置一个参数吧，默认是电脑，手机会单独进行判断。
            dd.device.base.getPhoneInfo({
                onSuccess: function(data) {
                    document.getElementById("phone").value = 1;
                },
                onFail: function(err) {
                    alert("获取设备信息失败！");
                }
            });
            //PC端钉钉执行此方法
            // if (DingTalkPC.ua.isDesktop && DingTalkPC.ua.isInDingTalk) {
            //     alert("你在用电脑看？");
            // }
        });

        function change(obj){
            var value = $(obj).find('option:selected').text();
            $('#datashow').val(value);
        }

    </script>
</head>
<!--<script>-->
<!--    dd.ready(function() {-->
<!--        var Phone = false;-->
<!--        dd.device.base.getPhoneInfo({-->
<!--            onSuccess: function(data) {-->
<!--                //现在就是手机端-->
<!--                Phone = true;-->
<!--            },-->
<!--            onFail: function(err) {-->
<!--                alert("测试出错");-->
<!--            }-->
<!--        });-->
<!--        dd.runtime.permission.requestAuthCode({-->
<!--            corpId : "dingf97ce2b254d1552e" ,  //企业id-->
<!--            onSuccess : function(result) {-->
<!--                var code = result.code;-->
<!--                $.ajax({-->
<!--                    url:"/SendCode",-->
<!--                    type:"post",-->
<!--                    dataType:"html",-->
<!--                    data:{-->
<!--                        "code":code,-->
<!--                        "phone":Phone-->
<!--                    },-->
<!--                    success:function(html){-->
<!--                        window.location.replace(html)-->
<!--                    },-->
<!--                    error:function (msg){-->
<!--                        alert("登陆失败！");-->
<!--                    }-->
<!--                })-->
<!--            },-->
<!--            onFail : function(err) {-->
<!--                alert('出错了, ' + err);-->
<!--            }-->
<!--        });-->
<!--    });-->
<!--</script>-->
<body>
<p id="demo" style="text-align: center">正在连接系统...请稍等...</p>

<form class="content" id="cont1" name="form1" function="POST" action="/SendCode">
    <input value="code获取" type="hidden" name="code" id="code">
    <!-- 手机的value默认是0，表示是电脑登录 -->
    <input value="0" type="hidden" name="phone" id="phone">
</form>

</body>
</html>